home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 September / Macworld (1998-09).dmg / Shareware World / Info / For Developers / MacZoop 1.8.3 / More Classes / Undo / ZUndoTask.h < prev   
Text File  |  1998-04-16  |  2KB  |  69 lines

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            MacZoop - "the framework for the rest of us"         
  5. *
  6. *
  7. *
  8. *            ZUndoTask.h            -- a generic object for implementing Undo
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21.  
  22. #pragma once
  23.  
  24. #ifndef __ZUNDOTASK__
  25. #define __ZUNDOTASK__
  26.  
  27.  
  28. class    ZWindow;
  29.  
  30.  
  31.  
  32. class    ZUndoTask
  33. {
  34. protected:
  35.     Str63        taskString;        // name of the task- menu shows "Undo <taskString>"
  36.     ZWindow*    itsTarget;        // window the task is intended for
  37.     Boolean        undone;            // if undone (if TRUE, menu shows Redo)
  38.     Boolean        isFirstTask;    // TRUE if this is the first task since file saved
  39.  
  40. public:
  41.     ZUndoTask( Str63 aTaskString, ZWindow*    aTarget );
  42.     ZUndoTask( const short strListID, const short strListIndex, ZWindow* aTarget );
  43.     virtual ~ZUndoTask() {};
  44.  
  45.     virtual void    Do();
  46.     virtual void    Undo();
  47.     virtual void    Redo();
  48.     virtual void    GetTaskString( Str63 aTaskStr );
  49.     
  50.     inline Boolean    IsUndone() { return undone; };
  51.     inline ZWindow*    GetUndoTarget() { return itsTarget; };
  52.     
  53.     inline void        SetIsFirstTask() { isFirstTask = TRUE; };
  54. };
  55.  
  56.  
  57. /*
  58.  
  59. To use this to implement Undo, you need to subclass it for each kind of undoable action
  60. you require. The application will keep hold of the last undo task and manage the Undo menu
  61. item, calling the task's Undo or Redo method as appropriate. The task string you supply when
  62. creating the task is appended to the menu item- e.g. "Undo Editing" if the task string was
  63. "Editing". Undo tasks are associated with windows- if the window no longer exists, the task
  64. will be deleted. Sending an undo task marks the window as dirty automatically.
  65.  
  66.  
  67. */
  68.  
  69. #endif